﻿using System.ComponentModel;
using VisualWip.Core;
using VisualWip.Core.Columns;
using VisualWip.Core.Utils;

namespace VisualWip.PresentationModel.Line
{
    public class LineColumnViewModel : ColumnViewModelBase
    {
        private readonly LineColumn _column;

        public LineColumnViewModel(Application application, LineColumn column, IColumnBuilder columnBuilder)
            : base(application, column, columnBuilder)
        {
            _column = column;
        }

        public int Thickness
        {
            get { return _column.Thickness; }
        }

        public bool IsHorizontal
        {
            get { return _column.IsHorizontal; }
        }


        public int X2
        {
            get { return IsHorizontal ? Width : 0; }
        }

        public int Y2
        {
            get { return IsHorizontal ? 0 : Height; }
        }

        public string Color
        {
            get { return _column.Color; }
        }

        protected override void ColumnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.ColumnPropertyChanged(sender, e);

            BubbleOnPropertyChanged(e, () => Color);
            BubbleOnPropertyChanged(e, ()=> Thickness);


            if (e.PropertyName == PropertyHelper.Name(() => Width) || e.PropertyName == PropertyHelper.Name(() => Width) || e.PropertyName == PropertyHelper.Name(()=> IsHorizontal))
            {
                OnPropertyChanged(this, () => X2);
                OnPropertyChanged(this, () => Y2);
            }
        }
    }
}